﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using Libreria.RFID.Negocio;
using Libreria.RFID.Modelo;

public partial class Objeto : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["cs"] = ConfigurationManager.ConnectionStrings["RFID"].ConnectionString;
    }
    protected void LinkBttnVolver_Click(object sender, EventArgs e)
    {

    }
    protected void FormView1_ModeChanged(object sender, EventArgs e)
    {

    }
    protected void FormView1_DataBound(object sender, EventArgs e)
    {
           }
    protected void NewButton_Click(object sender, EventArgs e)
    {

    }
    protected void FormView2_DataBound(object sender, EventArgs e)
    {
        FormView form = (FormView)sender;
        if (form.CurrentMode == FormViewMode.Insert)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["persona"]))
            {
                ((DropDownList)form.FindControl("DropDownList2")).SelectedValue = Request.QueryString["persona"];
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }
    protected void NewButton_Click1(object sender, EventArgs e)
    {

    }
    protected void FormView3_DataBound(object sender, EventArgs e)
    {
        FormView form = (FormView)sender;
        if (form.CurrentMode == FormViewMode.ReadOnly)
        {
            if (!string.IsNullOrEmpty(TextBox1.Text))
            {
                Label persona = (Label)form.FindControl("CodigopersonaLabel");
                if (persona != null)
                {
                    Int32 codigoPersona;
                    Int32.TryParse(persona.Text, out codigoPersona);
                    Persona personaNombre = (new PersonaNegocio()).consultarPersonasPorCodigo(codigoPersona, Session["cs"].ToString());
                    if (personaNombre != null)
                    {
                        persona.Text = personaNombre.Nombre;
                    }
                }
            }
        }
    }
    protected void odsRegistroDeObjeto_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
    {
        if (e.Exception.InnerException.InnerException.Message.Equals("Error"))
        {
            LabelMensaje.Text = string.Empty;
            LabelError.Text = e.Exception.InnerException.Message;
            PanelMensajes.Visible = true;
            e.ExceptionHandled = true;
        }
        else
        {
            LabelError.Text = string.Empty;
            LabelMensaje.Text = e.Exception.InnerException.Message;
            PanelMensajes.Visible = true;
            e.ExceptionHandled = true;
        }
    }

    protected void InsertCancelButton_Click(object sender, EventArgs e)
    {

    }
}
